package com.wzl.backend.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.wzl.backend.common.Result;
import com.wzl.backend.pojo.Comment;
import com.wzl.backend.service.CommentService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/comment")
@CrossOrigin("*")
public class CommentController {

    @Autowired
    CommentService commentService;

    @GetMapping("{id}")
    @ApiOperation("根据话题id查询评论")
    public Result getById(@PathVariable String id) {
        return Result.ok(commentService.getByTopicId(id));
    }

    @PostMapping("insert")
    @ApiOperation("添加一个评论")
    public Result insert(Comment comment) {
        return Result.ok(commentService.save(comment));
    }

    @PostMapping("delete/{id}")
    @ApiOperation("删除一个评论")
    public Result delete(@PathVariable String id) {
        return Result.ok(commentService.removeById(id));
    }


}
